//
// Created by Administrator on 2020/10/22.
//

#ifndef O5G_SRC_CCORE_PHY_RF_SRC_RFNNGIMPL_H_
#define O5G_SRC_CCORE_PHY_RF_SRC_RFNNGIMPL_H_

#include <stdint.h>
#include "../include/rfDef.h"

#ifdef __cplusplus
extern "C"
{
#endif

#define DEVNAME_NNG "nng"

int rf_nng_open(char* args, void** handler);

int rf_nng_open_multi(char* args, void** handler, uint32_t nof_channels);

const char* rf_nng_devname(void* h);

int rf_nng_close(void* h);

int rf_nng_start_rx_stream(void* h, int8_t now);

int rf_nng_start_rx_stream_nsamples(void* h, uint32_t nsamples);

int rf_nng_stop_rx_stream(void* h);

void rf_nng_flush_buffer(void* h);

int8_t rf_nng_has_rssi(void* h);

float rf_nng_get_rssi(void* h);

double rf_nng_set_rx_srate(void* h, double freq);

double rf_nng_set_rx_gain(void* h, double gain);

double rf_nng_get_rx_gain(void* h);

double rf_nng_get_tx_gain(void* h);

rf_info_t* rf_nng_get_info(void* h);

void rf_nng_suppress_stdout(void* h);

void rf_nng_register_error_handler(void* h, rf_error_handler_t error_handler, void* arg);

double rf_nng_set_rx_freq(void* h, uint32_t ch, double freq);

int
rf_nng_recv_with_time(void* h, void* data, uint32_t nsamples, int8_t blocking, time_t* secs, double* frac_secs);

int
rf_nng_recv_with_time_multi(void* h, void** data, uint32_t nsamples, int8_t blocking, time_t* secs, double* frac_secs);

double rf_nng_set_tx_srate(void* h, double freq);

double rf_nng_set_tx_gain(void* h, double gain);

double rf_nng_set_tx_freq(void* h, uint32_t ch, double freq);

void rf_nng_get_time(void* h, time_t* secs, double* frac_secs);

int rf_nng_send_timed(void*  h,
    void*  data,
    int    nsamples,
    time_t secs,
    double frac_secs,
    int8_t   has_time_spec,
    int8_t   blocking,
    int8_t   is_start_of_burst,
    int8_t   is_end_of_burst);

int rf_nng_send_timed_multi(void*  h,
    void*  data[4],
    int    nsamples,
    time_t secs,
    double frac_secs,
    int8_t   has_time_spec,
    int8_t   blocking,
    int8_t   is_start_of_burst,
    int8_t   is_end_of_burst);

#ifdef __cplusplus
}
#endif

#endif //O5G_SRC_CCORE_PHY_RF_SRC_RFNNGIMPL_H_
